package com.suny.thread_per_message;

import java.util.concurrent.ThreadFactory;

public class ThreadFactoryHost {
    private final Helper helper = new Helper();
    private final ThreadFactory factory;

    public ThreadFactoryHost(ThreadFactory factory) {
        this.factory = factory;
    }

    public void request(int count, char c) {
        System.out.println("      request(" + count + ", " + c + ") BEGIN");

        factory.newThread(new Runnable() {
            @Override
            public void run() {
                helper.handle(count, c);
            }
        }).start();
        System.out.println("      request( " + count + ", " + c + ") END");

    }
}
